﻿#include "ssRect2.h"


namespace StarSeeker
{

ssRect2::ssRect2(void)
{
	Zero();
}

ssRect2::ssRect2(ssfloat x, ssfloat y, ssfloat width, ssfloat height)
{
	InitByMinAndSize(x, y, width, height);
}

void ssRect2::InitByMinAndSize(ssfloat x, ssfloat y, ssfloat width, ssfloat height)
{
	m_x = x;
	m_y = y;
	m_width = width;
	m_height = height;
}

void ssRect2::InitByCenterAndSize(ssfloat x, ssfloat y, ssfloat width, ssfloat height)
{
	m_x = x-width*0.5f;
	m_y = y - height * 0.5f;
	m_width = width;
	m_height = height;
}

void ssRect2::InitByMinAndMax(ssfloat minx, ssfloat miny, ssfloat maxx, ssfloat maxy)
{
	m_x = minx;
	m_y = miny;
	m_width = maxx-minx;
	m_height = maxy - miny;
}

void ssRect2::Zero()
{
	m_x = m_y = m_width = m_height = 0.0f;
}

StarSeeker::ssfloat ssRect2::MaxY() const
{
	return m_y + m_height;
}

ssfloat ssRect2::MaxX() const
{
	return m_x + m_width;
}

ssfloat ssRect2::MinY() const
{
	return m_y;
}

ssfloat ssRect2::MinX() const
{
	return m_x;
}

ssVector2 ssRect2::Max() const
{
	ssVector2 ret(m_x + m_width, m_y + m_height);
	return ret;
}

ssVector2 ssRect2::Min() const
{
	ssVector2 ret(m_x, m_y);
	return ret;
}

ssVector2 ssRect2::Center() const
{
	ssVector2 ret(m_x+m_width*0.5f, m_y+m_height*0.5f);
	return ret;
}

}
